﻿using System.Collections.Generic;
using Lucid.ESA.ClientDataSystem.Domain.Common;

namespace Lucid.ESA.ClientDataSystem.Application.Responses
{
    public class ValidationErrorResponse : Response
    {
        protected List<ValidationErrorResponseMessage> _infos;
        protected List<ValidationErrorResponseMessage> _warnings;
        protected List<ValidationErrorResponseMessage> _errors;

        public ValidationErrorResponse(ValidationMessageCollection messages) : base(ResponseStatus.ValidationError)
        {
            _infos = new List<ValidationErrorResponseMessage>();
            _warnings = new List<ValidationErrorResponseMessage>();
            _errors = new List<ValidationErrorResponseMessage>();

            foreach (ValidationMessage message in messages.Infos)
            {
                _infos.Add(new ValidationErrorResponseMessage()
                {
                    Field = message.Field,
                    Text = message.Text
                });
            }

            foreach (ValidationMessage message in messages.Warnings)
            {
                _warnings.Add(new ValidationErrorResponseMessage()
                {
                    Field = message.Field,
                    Text = message.Text
                });
            }

            foreach (ValidationMessage message in messages.Errors)
            {
                _errors.Add(new ValidationErrorResponseMessage()
                {
                    Field = message.Field,
                    Text = message.Text
                });
            }
        }

        public List<ValidationErrorResponseMessage> Infos
        {
            get { return _infos; }
            set { _infos = value; }
        }

        public List<ValidationErrorResponseMessage> Warnings
        {
            get { return _warnings; }
            set { _warnings = value; }
        }

        public List<ValidationErrorResponseMessage> Errors
        {
            get { return _errors; }
            set { _errors = value; }
        }
    }
}
